package com.linshidream.intrachat.simplenio.packet.handler;

import com.linshidream.intrachat.simplenio.packet.context.ConnectionContext;

import java.io.IOException;

/**
 * Created on 2025/8/17 21:11
 *
 * @author linshidream
 * @version 1.0.0
 * @description 消息处理器
 */

public interface PacketHandler {

    /**
     * 通道激活
     * @param ctx
     * @throws IOException
     */
    void channelActive(ConnectionContext ctx) throws IOException;

    /**
     * 读数据
     * @param ctx
     * @param msg
     * @throws IOException
     */
    void channelRead(ConnectionContext ctx, String msg) throws IOException;

    /**
     * 通道关闭
     * @param ctx
     * @throws IOException
     */
    void channelInactive(ConnectionContext ctx) throws IOException;

    /**
     * 通道异常
     * @param ctx
     * @param e
     */
    void exceptionCaught(ConnectionContext ctx, Throwable e);
}
